package com.hangzhou.xyj.ui.fragment;

import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;

import com.hangzhou.xyj.R;
import com.hangzhou.xyj.ui.adapter.HomeStageVPAdapter;
import com.hangzhou.xyj.ui.fragment.base.BaseFragment;
import com.hangzhou.xyj.ui.widget.PagerSlidingTabStrip;

/**
 * 戏台
 * @author neo.duan
 *
 */
public class StageFragment extends BaseFragment implements OnClickListener{

	private PagerSlidingTabStrip mViewPagerTab;
	private ViewPager mViewPager;
	private HomeStageVPAdapter mAdapter;
	
	public StageFragment() {

	}
	
	@Override
	public void initTop() {
		enableTop(false);
		enableRefresh(false);
	}

	@Override
	public void initLayouts() {
		setContentView(R.layout.fragment_stage);
	}

	@Override
	public void initViews() {
		mViewPagerTab = findView(R.id.stage_tabs);
		mViewPager = findView(R.id.vp_main_stage);

		mViewPager.setAdapter(mAdapter = new HomeStageVPAdapter(getFragmentManager()));
		//向ViewPager绑定PagerSlidingTabStrip
		mViewPagerTab.setViewPager(mViewPager);
		mViewPager.setCurrentItem(0);
	}

	@Override
	public void initDatas() {

	}

	/**
	 * 重载下拉刷新方法，使用自己的加载方式
	 */
	@Override
	public void doRefresh() {
		int currentItem = mViewPager.getCurrentItem();
		BaseFragment fragment = (BaseFragment) mAdapter.getItem(currentItem);
		fragment.initDatas();
	}

	@Override
	public void initListeners() {
		mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
			@Override
			public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

			}

			@Override
			public void onPageSelected(int position) {
				switch (position) {
					case 0:

						break;
					case 1:

						break;
					case 2:

						break;
				}
			}

			@Override
			public void onPageScrollStateChanged(int state) {

			}
		});
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			/*case R.id.tv_stage_famous_expert:
				mViewPager.setCurrentItem(0);
				break;
			case R.id.tv_stage_famous_team:
				mViewPager.setCurrentItem(1);
				break;
			case R.id.tv_stage_hotspot:
				mViewPager.setCurrentItem(2);
				break;*/
		}
	}
}
